#include "file.h"
#include <stdio.h>

float read_voltage()
{
    float raw, offset, scale, value;
    read_file("/sys/bus/iio/devices/iio:device3/in_voltage1_raw", &raw);
    read_file("/sys/bus/iio/devices/iio:device3/in_voltage_offset", &offset);
    read_file("/sys/bus/iio/devices/iio:device3/in_voltage_scale", &scale);

    value = (raw + offset)*scale / 1000;

    return value;
}

int main()
{
    printf("%.1f V\n", read_voltage());
    return 0;
}
